package com.anosine.gpsl.android.presenter;

import com.anosine.gpsl.android.dao.AddFamilyNumberDao;
import com.anosine.gpsl.android.entity.ModifyPwdInfo;
import com.anosine.gpsl.android.impl.AddFamilyNumberDaoImpl;
import com.anosine.gpsl.android.presenter.BasePresenterActivity.OnLoadListener;
import com.anosine.gpsl.android.ui.AddFamilyNumberView;
import com.lidroid.xutils.util.LogUtils;

/**
 * @Title: AddFamilyNumberPresenter
 * @Package com.anosine.gpsl.android.presenter
 * @Description: 接收impl传递过来的JSON语句后的数据，并且改为实体后放入View的方法中传递给View
 * @author: sunny
 * @date: 2015-12-1
 * @version V1.0
 */
public class AddFamilyNumberPresenter extends BasePresenterActivity implements OnLoadListener{
	private AddFamilyNumberDao dao;
	private AddFamilyNumberView view;

	/**
	 * @Title: AddFamilyNumberPresenter(AddFamilyNumberView view)
	 * @Description: 构造方法，初始化
	 * @param: view
	 * @throws
	 */

	public AddFamilyNumberPresenter(AddFamilyNumberView view) {
		super();
		this.dao = new AddFamilyNumberDaoImpl(this);
		this.view = view;

	}

	/**
	 * @Title:loadAddFamilyNumber(String usermd5,String familynumbers)
	 * @Description: 添加亲情号调用接口参数赋值
	 * @param: usermd5 登录验证串
	 * @param: familynumbers 亲情号
	 * @return: 无
	 * @throws
	 */
	public void loadAddFamilyNumber(String usermd5,String familynumbers) {
		dao.getAddFamilyNumber(usermd5, familynumbers);
	}

	/**
	 * @Title: onLoadStart()
	 * @Description: 重写加载开始方法
	 * @param: 无
	 * @return: 无
	 * @throws
	 */

	@Override
	public void onLoadStart() {
		LogUtils.d("获取添加亲情号信息加载中。。");
	}

	/**
	 * @Title: onFailure()
	 * @Description: 重写加载失败方法
	 * @param: 无
	 * @return: 无
	 * @throws
	 */

	@Override
	public void onFailure() {
		LogUtils.d("获取添加亲情号信息加载失败。。");
	}

	/**
	 * @Title: onSuccess(Object obj)
	 * @Description: 重写加载成功方法
	 * @param: Object obj
	 * @return: 无
	 * @throws
	 */
	@Override
	public void onSuccess(Object obj) {
		ModifyPwdInfo res = (ModifyPwdInfo) obj;
		loadAddFamilyNumberSuccess(res);
	}

	/**
	 * @Title: loadAddFamilyNumberSuccess(ModifyPwdInfo res)
	 * @Description: 将传递过来的JSON语句解析后的数据改为实体后放入AddFamilyNumberView的方法中传递给View
	 * @param: Login res
	 * @return: 无
	 * @throws
	 */
	private void loadAddFamilyNumberSuccess(ModifyPwdInfo res) {
		this.view.setAddFamilyNumber(res);
	}
}
